﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using FaceSharp.Api.GraphApi;
using Newtonsoft.Json.Linq;

namespace FaceSharp.Api.Objects
{
    public class Insights : GraphBase
    {
        public Insights(IFacebookCore facebookCore): base(facebookCore)
        {
        }
        public string Get(long itemId)
        {
            Trace.Write("Begin Request", "GraphApi.GetInsights");

            var results = BaseGraphRequest("/" + itemId.ToString() + "/insights", new Dictionary<string, string>()
                    {
                        {"since", String.Format("{0:MMMM,yyyy}",DateTime.UtcNow.AddMonths(-1)) }
                    }, (rawResults) => {return JObject.Parse(rawResults);});
            Trace.Write("End Request", "GraphApi.GetInsights");
            return results.ToString();
        }
    }
}